package com.elm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.elm.model.Seller;
import com.elm.service.FuncService;
import com.elm.service.SellerService;
import com.elm.serviceimpl.FuncServiceImpl;
import com.elm.serviceimpl.SellerServiceImpl;

public class ShowFuncsController extends HttpServlet{
	SellerService ss = new SellerServiceImpl();
	FuncService fservice = new FuncServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session = req.getSession();
		Seller s = (Seller)session.getAttribute("currentSeller");
		int sid = s.getSellerid();
		String funcs =ss.getRoleBySid(sid).getFuncs();
		  resp.setCharacterEncoding("utf8");
		  PrintWriter  pw  =  resp.getWriter();
		    
		  pw.write(fservice.getFuncsByParentId(-1, funcs).toString());
	}
}
